<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<!-- .breadcrumb -->
	</div>
	<div class="page-content">
        
        <div class="page-header">
			<h1>批量导入</h1>
		</div>
		<div class="row">
			 <div class="col-xs-12">
				<!-- PAGE CONTENT BEGINS -->
					<form id="usrform" action="" enctype="multipart/form-data"  method="post">
				    	<div class="box-body" style="display: inline-block;width: 100%">
					        <div class="form-group col-xs-6">
					            <label>请选择excel</label>
					            <input name="excel" id='excel' type="file" class="form-control" style="border: 0;" check-type="required">
				            </div>
			            </div>
			            <div class="clearfix form-actions">
							<div class="col-md-offset-3 col-md-9" style="margin-left: 0;">
								<button id="submit" class="btn btn-info" type="button">
									<i class="icon-ok bigger-110" ></i>
									发放
								</button>
							</div>
						</div>
					</form>
			</div>
			<div class="col-xs-12" style="margin-top: 10px;">
				<table class="table table-striped table-bordered table-hover">
					<thead>
						<tr>
							<th>新增用户</th>
							<th>老用户</th>
							<th>失败用户</th>
							<th>导入时间</th>
						</tr>
					</thead>
					<tbody id='report'>
					</tbody>
					
				</table>
			</div>
		</div><!-- /.row -->
	</div><!-- /.page-content -->
</div><!-- /.main-content -->
<script type="text/javascript">
$("#usrform").validation();
//保存
$('#submit').click(function(){
	
	var form_data = new FormData();
	var excel = document.getElementById('excel').files[0];
	if(excel == undefined){
		alert('请选择excel');
		return;
	}
	form_data.append('excel',excel);
	showLoading('添加中,请稍后......');
	$.ajax({
		url:'<?php echo base_url()."admin/user/add_user_batch/"?>',
		type:'POST',
		data:form_data,
		contentType: false, // 注意这里应设为false
 		processData: false,
 		cache: false,
 		success:function(res){
 			
 			var data = JSON.parse(res);
 			if(data.status){
 				hideLoading();
 				alert('添加成功!');
 			}else{
 				hideLoading();
 				alert(data.msg);
 				console.log(data);
 			}
 			$('#report').append("<tr><td>"+data.info.new.length+"</td><td>"+data.info.old.length+"</td><td>"+data.info.failed.length+"</td><td>"+data.info.time+"</td></tr>");
 			
 		},
 		error:function(res){
 			hideLoading();
 			alert('error');
 			console.log(res);
 		}
	});
	
	// 
})
</script>